Use gint16 for GtkBorder
authorHavoc Pennington <hp@pobox.com>
Sat, 11 Sep 2010 23:25:57 +0000 (19:25 -0400)
committerHavoc Pennington <hp@pobox.com>
Mon, 13 Sep 2010 01:47:09 +0000 (21:47 -0400)
32K of border ought to be enough for any pixel dimensions. At least
until screens are so huge we start using doubles.

This saves a nice 64 bits of space when we have a GtkBorder
stored somewhere.

Signed integers are used to avoid surprising unsigned math
issues. Just search GTK's whole git log from inception
for "unsigned" if you want to find any number of commits
fixing signed/unsigned bugs.

https://bugzilla.gnome.org/show_bug.cgi?id=629387

gtk/gtksettings.c
gtk/gtkstyle.h

index 581806983976f75079eed1de2b492f7d731903fe..8690a9c777c444e9270b5b698b9bcf9063b67298 100644 (file)
@@ -1941,6 +1941,7 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
   GtkBorder border;
   GScanner *scanner;
   gboolean success = FALSE;
+  int left, right, top, bottom;
 
   g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
   g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
@@ -1948,11 +1949,15 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
   scanner = gtk_rc_scanner_new ();
   g_scanner_input_text (scanner, gstring->str, gstring->len);
 
-  if (get_braced_int (scanner, TRUE, FALSE, &border.left) &&
-      get_braced_int (scanner, FALSE, FALSE, &border.right) &&
-      get_braced_int (scanner, FALSE, FALSE, &border.top) &&
-      get_braced_int (scanner, FALSE, TRUE, &border.bottom))
+  if (get_braced_int (scanner, TRUE, FALSE, &left) &&
+      get_braced_int (scanner, FALSE, FALSE, &right) &&
+      get_braced_int (scanner, FALSE, FALSE, &top) &&
+      get_braced_int (scanner, FALSE, TRUE, &bottom))
     {
+      border.left = left;
+      border.right = right;
+      border.top = top;
+      border.bottom = bottom;
       g_value_set_boxed (property_value, &border);
       success = TRUE;
     }
index f3312baae1cb3dd723897cce0daa6b76ab923297..b425aa6d266a2891051be060cafa1f6a50722907 100644 (file)
@@ -416,10 +416,10 @@ struct _GtkStyleClass
  */
 struct _GtkBorder
 {
-  gint left;
-  gint right;
-  gint top;
-  gint bottom;
+  gint16 left;
+  gint16 right;
+  gint16 top;
+  gint16 bottom;
 };
 
 GType     gtk_style_get_type                 (void) G_GNUC_CONST;